<template>
	<view class="content">

		<!-- <view class="login_img"><image mode="aspectFill" src="/static/image/iamhe.png"></image></view> -->

		<view class="login_from">
			<u-form :model="HongUsers" :rules="rules" ref='myForm'>
				<u-form-item label="密码" prop="userpassword" labelWidth="100rpx">
					<u-input password v-model="HongUsers.userpassword" border="surround" clearable></u-input>
				</u-form-item>
				<u-form-item label="确认密码" prop="userpassword1" labelWidth="110rpx">
					<u-input password v-model="HongUsers.userpassword1" border="surround" clearable></u-input>
				</u-form-item>
			</u-form>
			<view class="login_from_dl">
				<button @click="denglu(eid)">修改</button>
			</view>

		</view>

	</view>
</template>
<script>
	export default {

		data() {
			return {
				user: {},
				verCode: "", //验证码
				width: 120,
				height: 45,
				eid: '',
				// 地区选择 start 
				//value3: [],
				//label3: '',
				//list1: areaData,
				// 地区选择 end 
				gouxSta: false,
				Qztime: '',
				QzyzmStare: false,
				Qztext: '获取验证码',
				HongUsers: {
					userpassword: '',
					userpassword1: ''
				},
				rules: {
					'userpassword': [{
						type: 'string',
						required: true,
						message: '请填写密码',
						trigger: ['blur', 'change'],
					}],
					'userpassword1': [{
							type: 'string',
							required: true,
							message: '请填写确认密码',
							trigger: ['blur', 'change'],
						},
						{
							trigger: 'blur',
							validator: (rule, value, callback) => {
								if (value !== this.HongUsers.userpassword) {
									callback(new Error('两次输入密码不一致'))
								} else {
									callback()
								}
							}
						}
					],

				},

			}
		},
		onLoad() {
			this.b();
		},
		methods: {
			b() {
				this.user = uni.getStorageSync('user');
				this.eid = this.user.eid
				console.log(this.eid)
			},
			denglu(eid) {

				this.$refs.myForm.validate().then(res => {
					this.userpassword=this.HongUsers.userpassword
					uni.request({
						url: 'http://localhost:8003/userproject/user/update/' + this.eid,
						data: 
							 this.HongUsers.userpassword
						,
						method: 'POST',
						success: (res) => {
							console.log("验证通过")
							console.log(this.HongUsers.userpassword)
							console.log(res.data)
							if (res.data==true) {
								console.log(res)
								uni.showToast({
									title: '修改成功',
									icon: 'success'
								})
								setTimeout(() => {
									uni.removeStorage({
										key: 'this.user',
										success: function(res) {
											uni.reLaunch({
												url: '../login/login'
											})
										}
									})
								}, 1000)
							} else {
								uni.showToast({
									title: '修改失败',
									icon: 'error'
								})
							}
						}
					})
				})

			},







			// 所属地区选择 end
		}
	}
</script>
<style>
	page {
		background: #fff;
	}

	.login_img {
		width: 100%;
		height: auto;
		margin-top: 90upx;
	}

	.login_img image {
		width: 170upx;
		height: 170upx;
		display: block;
		margin: 0px auto;
		border-radius: 50%;
	}

	.login_from {
		width: 100%;
		height: auto;
		box-sizing: border-box;
		padding: 20upx 8%;
	}

	.login_from_input {
		width: 100%;
		height: auto;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1px #eee solid;
		padding: 40upx 0px;
		margin: 0px auto;
	}

	.login_from_name {
		width: 20%;
	}

	.login_from_fun {
		width: 80%;
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		align-items: center;
	}

	.login_from_fun input {
		width: 100%;
		text-align: left;
		font-size: 14px;
	}


	.login_from_dl {
		width: 100%;
		height: 50px;
		line-height: 50px;
		margin-top: 150upx;
	}

	.login_from_dl button {
		width: 100%;
		height: 50px;
		line-height: 50px;
		background: #FF3B00;
		color: #fff;
		border-radius: 50px;
	}

	.logo_xieyi {
		width: 100%;
		height: 40px;
		line-height: 40px;
		display: flex;
		flex-direction: row;
		margin-top: 30upx;
		align-items: center;
		color: #444;
		font-size: 14px;
		justify-content: center;
	}

	.logo_xieyi label {
		font-size: 18px;
		margin-right: 1%;
		display: block;
		width: 15px;
		height: 15px;
	}

	.cuIcon-squarecheckfill {
		color: #FF3B00;
	}

	.logo_text text {
		color: #FF3B00;
	}

	.getyzm {
		width: 60%;
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		color: #FF3B00;
	}

	.cuicon {
		font-size: 18px;
	}

	.regFrom_tom_yzlabel {
		width: 60%;
		text-align: right;
	}

	.cuIcon-squarecheckfill {
		background: #FF3B00;
		position: relative;
		border: 2px #ccc solid;
		box-sizing: border-box;
		border-radius: 3px;
	}

	.cuIcon-square {
		background: #fff;
		border: 2px #ccc solid;
		box-sizing: border-box;
		border-radius: 3px;
	}
</style>
